#ifndef _CTORRENT_H_
#define _CTORRENT_H_

#include "cdownload.h"

#define BOOST_ASIO_SEPARATE_COMPILATION

#pragma GCC diagnostic push
#if BUOLA_COMPILER_CLANG
    #pragma GCC diagnostic ignored "-Wunused-private-field"
#endif
///\todo remove this once libtorrent has been fixed
#define BOOST_NO_CXX11_NOEXCEPT
#include <libtorrent/session.hpp>
#pragma GCC diagnostic pop

namespace buola { namespace bitdaemon {

class CTorrent : public CDownload
{
public:
    CTorrent(libtorrent::torrent_handle pHandle);
    virtual ~CTorrent();

    virtual std::wstring GetStatusString();
    virtual std::wstring GetName();

    libtorrent::torrent_status GetStatus()  {   return mHandle.status();    }
    const libtorrent::torrent_info &GetInfo()
                                            {   return mHandle.get_torrent_info();  }
    virtual void Pause();
    virtual void Resume();

    virtual double GetProgress();
    virtual size_t GetSize();
    virtual double GetDLSpeed();
    virtual double GetULSpeed();

    virtual int GetFileCount();
    virtual std::string GetFileNameAt(int i);

    ///\todo change to a type i like more
    void GetFileProgress(std::vector<int64_t> &pProgress)       {   mHandle.file_progress(pProgress);       }
    void SetPriorities(const std::vector<int> &pPriorities)     {   mHandle.prioritize_files(pPriorities);  }
    virtual void SetPriority(int pIndex,int pPriority);

    virtual int GetTrackerCount();
    virtual io::CURI GetTrackerURIAt(int i);
    virtual void AddTracker(const io::CURI &pURL);

private:
    libtorrent::torrent_handle mHandle;
    std::vector<int> mPriorities;
};

/*namespace bitdaemon*/ } /*namespace buola*/ }

#endif
